<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.joinhawaii.admin.sales.*" %>
<%

	HashList code001	= CommonUtil.getCodeList("001");	//섬코드
	HashList code125	= CommonUtil.getCodeList("125", "전체");	//부서


	String s_travel_start_dt	= StringUtil.nvl(request.getParameter("s_travel_start_dt"), TODAY.substring(0,6)+"01");
	String s_travel_end_dt		= StringUtil.nvl(request.getParameter("s_travel_end_dt"), TODAY);
	String s_customer_name		= StringUtil.toHan(request.getParameter("s_customer_name"));
	String s_dept_code			= StringUtil.toHan(request.getParameter("s_dept_code"));

	HashMap infos = new HashMap();
	infos.put("travel_start_dt",	s_travel_start_dt);
	infos.put("travel_end_dt",	s_travel_end_dt);
	infos.put("customer_name", s_customer_name);
	infos.put("dept_code", s_dept_code);

	SalesDAO dao 	= new SalesDAO();
	HashList list 	= dao.selectAccountList(infos);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>조인하와이</title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#s_name').focus().select();
		$('#s_travel_start_dt').mask('9999.99.99').datepicker();
		$('#s_travel_end_dt').mask('9999.99.99').datepicker();
	});



	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/admin/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/admin/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>정산관리</h1>
				<p>관리자 > 견적관리 > <b>정산관리</b></p>
			</div>
			<div class="clear line_01"></div>

			<form name="searchForm" id="searchForm" method="post" action="./accountList.jsp">

			<table cellpadding="0" cellspacing="0" class="table_01 mt15">
			<colgroup>
				<col width="100px" />
				<col width="220px" />
				<col width="100px" />
				<col width="120px" />
				<col width="100px" />
				<col  />
			</colgroup>
			<tr>
			    <th><p>출발일</p></th>
			    <td>
					<input type="text" name="s_travel_start_dt" id="s_travel_start_dt" value="<%=s_travel_start_dt %>" class="w80 c"/>
					~ <input type="text" name="s_travel_end_dt" id="s_travel_end_dt" value="<%=s_travel_end_dt %>" class="w80 c"/>


				</td>
			    <th><p>부서</p></th>
			    <td>
			    	<select name="s_dept_code" class="w80">
					<%= StringUtil.makeOption(code125, s_dept_code) %>
					</select>
				</td>
				<th><p>고객명</p></th>
			    <td class="brx">
					<input type="text" name="s_customer_name" id="s_customer_name" value="<%=s_customer_name %>" class="w120"/>
				</td>
			</tr>
			</table>

			<div class="mt10 mb10 r">
				<input type="image" src="/images/admin/btn_search.gif" class="button"/>
				<a href="#nohref" onclick="fnSave()"><img src="/images/admin/btn_save.gif"></a>
			</div>

			</form>

			<div class="search_result">검색결과 : <%= list.size() %>건</div>



		    <table cellpadding="0" cellspacing="0" class="table_04">
				<colgroup>
					<col width="40px"/>
					<col />
					<col width="80px"/>
					<col width="80px"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
					<col width="55"/>
				</colgroup>
				<thead>
					<tr>
						<th rowspan="2"><p>No</p></th>
						<th rowspan="2"><p>고객명</p></th>
						<th rowspan="2"><p>출발일</p></th>
						<th rowspan="2"><p>도착일</p></th>
						<th colspan="2"><p>호텔</p></th>
						<th colspan="2"><p>주내선</p></th>
						<th colspan="2"><p>선택관광</p></th>
						<th colspan="2"><p>렌터카</p></th>
						<th colspan="2"><p>보험</p></th>
						<th colspan="2"><p>전체</p></th>
					</tr>
					<tr>
						<th><p>매출</p></th>
						<th><p>수익</p></th>
						<th><p>매출</p></th>
						<th><p>수익</p></th>
						<th><p>매출</p></th>
						<th><p>수익</p></th>
						<th><p>매출</p></th>
						<th><p>수익</p></th>
						<th><p>매출</p></th>
						<th><p>수익</p></th>
						<th><p>매출</p></th>
						<th><p>수익</p></th>
					</tr>
				</thead>
				<tbody id="list">
			<%
				double totalHotelSum = 0;
				double profitHotelSum = 0;
				double totalFlySum = 0;
				double profitFlySum = 0;
				double totalEnjoySum = 0;
				double profitEnjoySum = 0;
				double totalCarSum = 0;
				double profitCarSum = 0;
				double totalInsureSum = 0;
				double profitInsureSum = 0;
				double totalSum = 0;
				double profitSum = 0;

				for (int i = 0; i < list.size(); i++) {

					totalHotelSum 	+= list.getDouble("total_usd_hotel", i);
					profitHotelSum 	+= list.getDouble("profit_usd_hotel", i);
					totalFlySum 	+= list.getDouble("total_usd_fly", i);
					profitFlySum 	+= list.getDouble("profit_usd_fly", i);
					totalEnjoySum 	+= list.getDouble("total_usd_enjoy", i);
					profitEnjoySum 	+= list.getDouble("profit_usd_enjoy", i);
					totalCarSum 	+= list.getDouble("total_usd_car", i);
					profitCarSum 	+= list.getDouble("profit_usd_car", i);
					totalInsureSum 	+= list.getDouble("total_usd_insure", i);
					profitInsureSum += list.getDouble("profit_usd_insure", i);
					totalSum 		+= list.getDouble("total_usd", i);
					profitSum 		+= list.getDouble("profit_usd", i);
			%>
					<tr>
						<td class="c">
							<%= list.get("est_no", i) %>
						</td>
						<td><%= list.get("customer_name", i) %></td>
						<td class="c"><%= StringUtil.toDate(list.get("travel_start_dt", i)) %></td>
						<td class="c"><%= StringUtil.toDate(list.get("travel_end_dt", i)) %></td>
						<td class="r"><%= list.get("total_usd_hotel", i) %></td>
						<td class="r"><%= list.get("profit_usd_hotel", i) %></td>
						<td class="r"><%= list.get("total_usd_fly", i) %></td>
						<td class="r"><%= list.get("profit_usd_fly", i) %></td>
						<td class="r"><%= list.get("total_usd_enjoy", i) %></td>
						<td class="r"><%= list.get("profit_usd_enjoy", i) %></td>
						<td class="r"><%= list.get("total_usd_car", i) %></td>
						<td class="r"><%= list.get("profit_usd_car", i) %></td>
						<td class="r"><%= list.get("total_usd_insure", i) %></td>
						<td class="r"><%= list.get("profit_usd_insure", i) %></td>
						<td class="r"><%= list.get("total_usd", i) %></td>
						<td class="r"><%= list.get("profit_usd", i) %></td>
					</tr>
			<%	} %>
					<tr>
						<td class="sum c" colspan="4">
							합계
						</td>
						<td class="sum r"><%= totalHotelSum %></td>
						<td class="sum r"><%= profitHotelSum %></td>
						<td class="sum r"><%= totalFlySum %></td>
						<td class="sum r"><%= profitFlySum %></td>
						<td class="sum r"><%= totalEnjoySum %></td>
						<td class="sum r"><%= profitEnjoySum %></td>
						<td class="sum r"><%= totalCarSum %></td>
						<td class="sum r"><%= profitCarSum %></td>
						<td class="sum r"><%= totalInsureSum %></td>
						<td class="sum r"><%= profitInsureSum %></td>
						<td class="sum r"><%= totalSum %></td>
						<td class="sum r"><%= profitSum %></td>
					</tr>
				</tbody>
			</table>

		</div>
	</div>
</div>
</body>
</html>
